package com.ruoyi.web.controller.app;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.numericalselection.domain.GmCategory;
import com.ruoyi.numericalselection.domain.GmInventory;
import com.ruoyi.numericalselection.domain.dao.GmInventoryDao;
import com.ruoyi.numericalselection.service.IGmCategoryService;
import com.ruoyi.numericalselection.service.IGmInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@RestController
@RequestMapping("/app")
public class GmCommodityApp extends BaseController {
    @Autowired
    private IGmCategoryService iGmCategoryService;
    @Autowired
    private IGmInventoryService iGmInventoryService;

    /**
     * app 查询游戏
     *
     * @param type
     * @return
     */
    @GetMapping("/getGm/{type}")
    public AjaxResult getGm(@NotEmpty @PathVariable("type") String type) {
        return success(iGmCategoryService.getGm(type));
    }

    /**
     * 显示游戏
     */
    @GetMapping("gmList")
    public AjaxResult gmList() {
        List<GmCategory> list = iGmCategoryService.selectAppGmCategoryList();
        return success(list);
    }

    /**
     * 默认推荐账号
     */
    @GetMapping("accList")
    public TableDataInfo accList(GmInventory gmInventory) {
        startPage();
        List<GmInventory> list = iGmInventoryService.selectAppGmInventoryList(gmInventory);
        return getDataTable(list);
    }

    /**
     * 查询详细信息
     */
    @GetMapping("getAccByid/{id}")
    public GmInventoryDao getAccByid(@PathVariable("id") Long id) {
        return iGmInventoryService.selectJoinById(id);
    }


    /**
     * 排序
     */
    @GetMapping("gmAccList")
    public TableDataInfo gmAccList(GmInventoryDao gmInventory) {
        startPage();
        List<GmInventory> list = iGmInventoryService.gmAccList(gmInventory);
        return getDataTable(list);
    }


}
